
package org.openeai.lite.console.actionhandlers;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import org.apache.log4j.Logger;
import org.openeai.lite.common.exception.OpenEAIException;


@ManagedBean(name = "appLauncherActionHandler")
@RequestScoped
public class AppLauncherActionHandler
{

    @SuppressWarnings("unused")
    private static Logger log = Logger.getLogger(AppLauncherActionHandler.class);

    public void startJConsole() throws OpenEAIException
    {
        String basedir = System.getProperty("java.home");
        String app = basedir + "\\..\\bin\\jconsole.exe";
        String param = "service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/jmxrmi";
        try
        {
            log.info("Trying to execute external program " + app);
            Process p = Runtime.getRuntime().exec(new String[]{app, param});
        }
        catch (Exception e)
        {
            throw new OpenEAIException(e);
        }
    }
}
